/**
 * Created by guojianyu on 2016/3/30.
 */
myApp.config(function ($routeProvider) {
    $routeProvider.when('/myFood/viewAll', {
        templateUrl: 'myFood/viewAll',
        controller: 'myFoodController'
    })

});
myApp.service('myFoodListService', function ($http) {
    var doRequest = function () {
        return $http.get('myFood/listAll');
    }
    return {
        myFoodList: function () {
            return doRequest();
        }
    };
});
myApp.controller('myFoodController', function ($scope, $location, $http, myFoodListService,Notify) {
    /*获取表单数据*/
    myFoodListService.myFoodList().success(function (response) {
        $scope.myFoods = response;
    });
    /*商家审核状态*/
    $scope.enabled=function(myFood){
        $scope.data=myFood;
        $http.post('myFood/enabled',$scope.data).success(
            function(){
                Notify.success('商家状态已修改为审核已通过');
                myFoodListService.myFoodList().success(function (response) {
                    $scope.myFoods = response;
                });
            }).error(
            function(){
                Notify.error('error');
            }
        );
    };
});

